﻿import QtQuick 2.0
import "../components"
import QtCharts 2.3
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.2
import QtQuick.Controls 2.12
import QtMultimedia 5.14
Rectangle {
    width: parent.width
    height: parent.height
    property int type: 0
    property string xh:""
    property string syzj: ""
    property bool ispbv: false

    signal refre()

    onVisibleChanged: {

    }

    Row{
        anchors.fill: parent

        // 名称
        Text{
            id: num
            height: 40*dp;
            width: parent.width*0.2
            font.pixelSize: config.fontsize
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            anchors.verticalCenter: parent.verticalCenter
            text: xh
        }

        // 实验组件
        Text{
            id: code
            height: 40*dp;
            width: parent.width*0.6
            font.pixelSize: config.fontsize
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            anchors.verticalCenter: parent.verticalCenter
            text: syzj
        }
        // 操作
        Item{
            height: parent.height; width: parent.width*0.2
            CustomSwitchButton{
                height: 24*dp; width: 40*dp
                anchors.centerIn: parent
                id: ispb
                checked: ispbv
                enabled: {
                    if(type===3){
                        return xh==="8"||xh==="9"||xh==="11"
                    }else if(type===4){
                        return xh==="6"||xh==="7"||xh==="8"||xh==="9"
                    }
                }
                color: {
                    if(checked&&enabled){
                        return config.themeColor
                    }else if(!checked&&enabled){
                        return "#CCCCCC"
                    }else if(checked&&!enabled){
                        return "#E5F0FF"
                    }else if(!checked&&!enabled){
                        return "#E5F0FF"
                    }
                }
//                checked ? config.themeColor : "#CCCCCC" enabled?config.themeColor:"#E5F0FF"
                CustomTooltip{
                    visible: parent.isHovered
                    text: "是否启用"
                }
                onClicked: {
                    ispbv=!ispbv
                    refre()
                }
            }
        }

    }
    Rectangle{
        x:0*dp
        y:parent.height-2*dp
        height: 1.2*dp
        width: parent.width
        color: "#DEDEDE"
    }



}
